<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:9pt; font-weight:400; font-style:normal;">
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--select * from sysindexes where name = 'PK_ListTimePoint'</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--go</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--select * from sysindexes where name = 'PK_ListTimePoint' and id = object_id('dbo.ListTimePoint')</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--go</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--/****** Object:  UserDefinedFunction [dbo].[TestFunction]    Script Date: 09.03.2019 0:47:59 ******/</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">SET ANSI_NULLS ON</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">GO</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">SET QUOTED_IDENTIFIER ON</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">GO</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">ALTER FUNCTION [dbo].[TestFunction]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--create FUNCTION [dbo].[Fn_IndexExist]</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">(</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">@STR_IndexName VARCHAR(100) --О б ъ я в л е н и е в х о д я щ и х п а р а м е т р о в</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">RETURNS INT  --Т и п в о з в р а щ а е м о г о р е з у л ь т а т а</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">BEGIN</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">	DECLARE @bln_IndexExist INT;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">	--if exists (select * from sysindexes where name = 'PK_ListTimePoint' and id = object_id('dbo.ListTimePoint'))</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">	if exists (select * from sysindexes where name = @STR_IndexName)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">		SET @bln_IndexExist = 1;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">	ELSE</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">		SET @bln_IndexExist=0;</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">	RETURN @bln_IndexExist</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">END</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">GO</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--В ы з о в ф у н к ц и и . П о л у ч е н и е н а и м е н о в а н и я к о н к р е т н о г о т о в а р а</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">SELECT dbo.Fn_IndexExist('NonClusteredIndex-id_hour_Decl') AS Ibv</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">--PK_ListDatePJI</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">SELECT dbo.Fn_IndexExist('PK_ListDatePJI') AS Ibv</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">create</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">table</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> dbo.t1 (i </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">int</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;">go</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">create</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">table</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> dbo.t2 (i </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">int</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;">go</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">create</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">index</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> ix_i </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">on</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> dbo.t1(i)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;">go</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">create</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">index</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> ix_i </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">on</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> dbo.t2(i)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;">go</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">select</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> * </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">from</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#00aa00;">sysindexes</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">where</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> name = </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#ff0000;">'ix_i'</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;">go</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">select</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> * </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">from</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#00aa00;">sysindexes</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#0000ff;">where</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> name = </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#ff0000;">'ix_i'</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#777777;">and</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;"> id = </span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#ff00ff;">object_id</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;">(</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; color:#ff0000;">'dbo.t1'</span><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt;">)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Courier New,Courier,sans-serif'; font-size:11pt; background-color:#eff0f1;">go</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:11pt;"><br /></p></body></html>